#pragma once

#include <SDL.h>
#include <SDL_ttf.h>
#include <SDL_mixer.h>

#include <vector>
using namespace std;

class GameBase
{
public:
	GameBase(int x, int y) : m_x(x), m_y(y), m_Active(true) {}
	virtual ~GameBase() {}

	// create set of actions for all objects
	typedef enum Actions_e { None, Fire, Select, Attack } Event;
	typedef enum ActionReturn_e { NoReturn, Hit, Selected } ActionReturn;

	// pure virtual must be overriden in derived classes
	// returns 0 for success, all other values failures  
	virtual int Draw(SDL_Surface* pSurface) = 0;  
	virtual int Move(int x, int y) = 0;  

	// Action can return a new object or 0 for no change
	virtual ActionReturn Action(Event action,int inputX, int inputY) = 0;

	// give out object position
	virtual void GetPosition(int& x, int& y) const { x = m_x; y = m_y; } 	
	virtual bool GetActive() const { return m_Active; }
		
protected:
	int m_x;
	int m_y;
	bool m_Active;
};

class BitmapObjectStatic : public GameBase
{
public:
			BitmapObjectStatic(int x, int y, char* pGraphicPath); 
	virtual ~BitmapObjectStatic();

	virtual int Draw(SDL_Surface* pWorldSurface);
	virtual int Move(int x, int y);
	virtual ActionReturn Action(Event action,int inputX, int inputY);

private:
	SDL_Surface* m_Surface;
};

class BitmapObject : public GameBase
{
public:
			BitmapObject(int x, int y, char* pGraphicPath); 
	virtual ~BitmapObject();
	
	 
	virtual int Draw(SDL_Surface* pWorldSurface);
	virtual int Move(int x, int y);
	virtual ActionReturn Action(Event action,int inputX, int inputY);

private:
	SDL_Surface* m_Surface;
};

typedef vector<SDL_Surface*> SurfaceVector;

class BitmapAnimatedObject : public GameBase
{
public:
			BitmapAnimatedObject(int x, int y, char* pGraphicPathName, int NumberFrames, int FrameDelay, bool loop, int m_Xmove, int m_Ymove, bool collisions ); 
	virtual ~BitmapAnimatedObject();

	virtual int Draw(SDL_Surface* pWorldSurface);
	virtual int Move(int x, int y);
	virtual ActionReturn Action(Event action,int inputX, int inputY);

private:
	SurfaceVector m_SurfaceVector;
	int	m_CurrentFrame;
	bool m_Loop; 
	bool m_collisions;
	int m_Xmove;
	int m_Ymove;
	unsigned int m_FrameDelay;
	unsigned int m_LastUpdate;
};

class TextObjectStatic : public GameBase
{
public:
			TextObjectStatic(int x, int y, char* pFont, int textSize); 
	virtual ~TextObjectStatic();

	virtual int Draw( SDL_Surface* pWorldSurface);
	virtual int SetText( SDL_Surface* pWorldSurface, const char* Text, unsigned char Red, unsigned char Green, unsigned char Blue);
	virtual int Move(int x, int y);
	virtual ActionReturn Action(Event action,int inputX, int inputY);

private:
	int m_TextSize;
	char* Text; 
	SDL_Surface* m_Surface;
	TTF_Font* m_Font;
 
};
